<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="copyright" content="Tencent"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
	<title>参加活动成功</title>
	<link href="<%=path%>/favicon.ico" rel="shortcut icon">
<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/public.css" />
	<link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/marketing.css" />
	<link rel="stylesheet" href="<%=path%>/css/marketing/index.css"/>
</head>
<body class="s_activity_body" style="background:#fff">

<%--     <div class="k_title1">
        <img src="<%=path%>/images/marketing/icon_home.png" />
    </div> --%>
    <%-- <div hidden="" id="editor"></div>
    <div hidden="" class="s_slide">
        <ul class="fix">
            
        </ul>
    </div>
   
    <ul hidden="" class="s_detailed fix">
        <li id="huanjing">
            
        </li>
 	<li hidden="" id="li_address"><em><img
				src="<%=path%>/images/marketing/icon_phones.png" /></em>
		</li>
		<a href="javascript:IntentBranch();"><li id="store_num"><span class="into"></span></li></a>
    </ul> --%>

    <div class="k_activity" style="margin-top:100px;">
<!--         <h3 id="h3_price">
			<aa id="unitPrice2"></aa>
				&nbsp;&nbsp;<span><h id="priceHint"></h><em id="groupPrice2"></em></span>
			</h3>
        <p class="s_rule">活动细则</p> -->
        <div class="s_hdjs">
            <span>已参与</span>
            <p id="tishi" style="margin-top:18px;">恭喜你成功参与本次活动</p>
            <div id="couponTiShi" hidden="" style="text-align:center">验证码：<b id="coupon_code" style="color:red;"></b></div>
            <p id="smsTiShi" hidden="" style="margin-top:18px;">验证码即将发送到您的手机中，为了避免您的手机收不到短信<b style="color:red;">请拷贝或截屏保存优惠券码</b></p>
            <p id="emailTiShi" hidden="" style="margin-top:18px;">验证码即将发送到您的邮箱中，为了避免您的手机收不到邮件<b style="color:red;">请拷贝或截屏保存优惠券码</b></p>
        </div>
    </div>

    <div style="position:absolute;bottom:30px;width:100%;">
	    <ul class="s_footer">
	
	    </ul>
	    <div class="col-xs-12 col-sm-12 stern">
	                                                    zhfeat提供技术服务
	    </div>
    </div>
   
   <%--  <div class="s_popups">
        <div class="s_detailed_rule">
            <p>活动细则</p>
            <em><img src="<%=path%>/images/marketing/k_close.png" /></em>
            <ul id="activity_detail_rule">
               
            </ul>
        </div>
    </div> --%>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    <script src="<%=path%>/js/marketing/swiper-3.2.7.min.js"></script>
    <script src="<%=path%>/js/marketing/jquery.iosslider.js"></script>
    <script src="<%=path%>/js/marketing/jquery.lt_slide.js"></script>
    <script>
    var customer;
    var activity_name;
    
    var couponCode;
    var customer_id;
        $(function(){
        	customer_id=getQueryString("customer_id");
        	activity_id = getQueryString("activity_id");
			activity_type = getQueryString("type");
			couponCode= getQueryString("join");
			cid= getQueryString("cid");
			shareUrl= getQueryString("shareUrl");
            getActivityDetail();
            activityStore();
            console.log("coupon_code----->"+couponCode);
           
        });
       
        /* var mySwiper = new Swiper ('.swiper-container', {
      
            slidesPerView : 4,
            slidesPerGroup : 4,
            loop: true,

            // 如果需要分页器
            pagination: '.swiper-pagination',
        
        });
        $('.s_rule').click(function(){
            $('.s_popups').show();
            $('.s_detailed_rule').show();
        });
        $('.s_detailed_rule em').click(function(){
            $('.s_popups').hide();
            $('.s_detailed_rule').hide();
        }); */
        
        
        
        //获取活动信息
        function getActivityDetail(){
        	
			var url="<%=path%>/activity/browseActivityContent";
			$.post(url, {
				"activity_type" : activity_type,
				"cid" : cid,
				"activity_id" : activity_id,
				"customer_id" : customer_id,
			}, function(data) {
				
				if (data.status == 200) {
					
					setActivityHtml(data.data);
				} else {
				}
			});
        }
        
        
        
      //设置活动信息
		function setActivityHtml(data) {
			/* $(document).attr("title",data.name); */
			/* document.title=data.name; */
			activity_name=data.name;
			 if(data.coupon_send_type=="send_email"){
				 
					$('#smsTiShi').hide();
					$('#emailTiShi').show();
				}else{
					$('#smsTiShi').show();
					$('#emailTiShi').hide();
				}
	            if(StringEmpty(couponCode)){
//	            	$('#coupon_code').html("验证码"+couponCode);
	            	$('#coupon_code').html(couponCode);
	             	$('#smsTiShi').show();
	            	$('#couponTiShi').show();
	            	$('#emailTiShi').hide();
	            }else{
	            	$('#smsTiShi').hide();
	            	$('#couponTiShi').hide();
	            	
	            }
			
			
			var tag=data.tag;
			var title='';
			var description='';
			var activity_detail_rule='';
			var tishi='';
			<%-- if(tag=="defined_text"){
				$('#editor').html(data.description);
				$('.s_slide').hide();
				$('.s_popups').hide();
				$('#h3_price').hide();
				$('.s_rule').hide();
				
				if(StringEmpty(data.remarks)){
					var background_color=data.remarks;
					$(".s_activity_body").css("background-color",background_color);
					$(".k_activity").css("background-color",background_color);
					$(".s_detailed").css("background-color",background_color);
					$(".stern").css("background-color",background_color);
					$("#li_address").css("background-color",background_color);
					
				}
			}else{
				setBannerHtml(data.pic_url);
				
				if(StringEmpty(data.discount_price)){
					$("#unitPrice2").text(data.discount_price);
				}else{
					console.log("----->");
					$("#h3_price").hide();
				}
				if(StringEmpty(data.original_price))
					$("#groupPrice2").text(data.original_price);
				$('#activity_detail_rule').html(data.detail_rule);
				if(StringEmpty(data.bak2))
					$("#priceHint").text(data.bak2);
				
				console.log("data.equipment_facilities--------->"+data.equipment_facilities);
				if(StringEmpty(data.equipment_facilities)){
					var temp=data.equipment_facilities;
					var equipment_facilities=temp.split(",");
					var equipmenHtml='';
					for(var i in equipment_facilities){
						equipmenHtml+='<span><img src="<%=path%>/images/marketing/s_dg.png" />'+equipment_facilities[i]+'</span>';
					}
					$('#huanjing').html(equipmenHtml);
				}else{
					$('#huanjing').hide();
				}
			}
			
			title+='<p><img src="<%=path%>/images/marketing/icon_home.png"/>'
					+ data.name + '</p>';
			activity_detail_rule += '<li>' + data.detail_rule + '</li>';
			//tishi+='<p>恭喜您成功参与本活动</p>';
			/* $('.k_title1').html(title); */
			$('#activity_detail_rule').html(activity_detail_rule);
	 --%>		//$('#tishi').html(tishi);
			
			if(StringEmpty(data.weixin_qrcode)||StringEmpty(data.weibo_qrcode))
				$(".s_footer").append('<li style="width:100%;margin-bottom:8px"><font color="black" size="3"> 扫一扫  请关注 </font></li>');
			if(StringEmpty(data.weixin_qrcode)&&!StringEmpty(data.weibo_qrcode)){
				console.log("weixin--->");
				var html_weixin='<li style="width:100%"><img id="weixin_qrcode" src="'+data.weixin_qrcode+'" /><p>微信二维码</p></li>';
				$(".s_footer").append(html_weixin); 
			}else if(StringEmpty(data.weixin_qrcode)){
				var html_weixin='<li><img id="weixin_qrcode" src="'+data.weixin_qrcode+'" /><p>微信二维码</p></li>';
				$(".s_footer").append(html_weixin); 
			}
			
            if(StringEmpty(data.weibo_qrcode)&&!StringEmpty(data.weixin_qrcode)){
            	console.log("weibo_qrcode");
            	var html_weibo='<li style="width:100%"><img id="weibo_qrcode" src="'+data.weibo_qrcode+'" /><p>微博二维码</p></li>';
				$(".s_footer").append(html_weibo); 
			}else if(StringEmpty(data.weibo_qrcode)){
				var html_weibo='<li><img id="weibo_qrcode" src="'+data.weibo_qrcode+'" /><p>微博二维码</p></li>';
				$(".s_footer").append(html_weibo); 
			}
            
            var body = document.getElementsByTagName('body')[0];
			document.title = data.name;
			var iframe = document.createElement("iframe");
			iframe.style.display="none";
			iframe.setAttribute("src", "http://named.cn/page/take/img/icon_phone.png");
			var d = function() {
			    setTimeout(function() {
			        iframe.removeEventListener('load', d);
			        document.body.removeChild(iframe);
			    }, 0);

			};
			iframe.addEventListener('load', d);
			document.body.appendChild(iframe);
           
            
		}
		//设置轮播图
		function setBannerHtml(activity_pics) {
			var html = '<ul id="banner" class="fix">';
			pics = activity_pics.split(",");
			for (var i = 0; i < pics.length; i++) {
				var pic=pics[i];
				html += '<li> <img src="'+pic+'" />';
				html += '<div class="s_slide_con">';
				/* html += '<h4>'+activity_name+'<a href="javascript:;"><img src="images/icon_dh.png" />18993</a>';
				html += '<a href="javascript:;"><img src="images/icon_heart.png" />18993</a>'; */
				html += '<h4></h4></div></li>';
			}
			html += '</ul>';
			$('.s_slide').html(html);
			$('.s_slide').lt_slide({
				autoSlide : true,
				autoSlideTimer : 300000
			});
		}
        
        //获取url的参数
		function getQueryString(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return unescape(r[2]);
			return null;
		}
        
		 //获取活动门店信息
	    function activityStore(){
	    	var url = "<%=path%>/activityStore/query";
	    	$.post(url,{
				"cid" : cid,
				"activity_id" : activity_id,
	    	},function(data){
	    		
	    		if(data.error_code == "0"){
	    			var stores=data.data;
	    			$('#li_address').text("地址:"+stores[0].name);
			    	$('#store_num').text("全部"+stores.length+"家分店");
	    		}else{
	    			$(".s_detailed").hide();
	    		}
	    	});
	    }
		 //跳转分店
	    function IntentBranch(){
	    	   window.location.href = "<%=path%>/api/bm/ui/branch?id="+activity_id+"&cid="+cid;
	       }
	  //判断字符串是否为空
		function StringEmpty(content) {
			if (content == "undefined" ||content == undefined || content == "" || content == null) {
				return false;
			} else {
				return true;
			}
		}
    </script>
</body>
</html>